#![no_std]
#![no_main]


// 导入HAL库
extern crate hal;
use hal::include_boot_asm;
// 必需的panic处理函数
use core::panic::PanicInfo;
use hal::hal_entry;
use hal::println;

#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
    // 打印panic信息
    if let Some(location) = info.location() {
        hal::ERROR!("Panic occurred in {} at line {}", location.file(), location.line());
    } else {
        hal::ERROR!("Panic occurred but location information not available");
    }
    
    // 打印panic消息
    hal::ERROR!("{}", info);
    
    // 输出堆栈跟踪信息(如果有的话)
    hal::WARN!("System halted");
    
    // 无限循环防止返回
    loop {}
}

// 内核主函数
#[unsafe(no_mangle)]
pub fn kernel_main() -> ! {
    println!("kernel_main\n");
    loop {}
}

include_boot_asm!();
hal_entry!(kernel_main);